home *** CD-ROM | disk | FTP | other *** search
- #include <egb.h>
- #include <snd.h>
- #include <malloc.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <io.h>
- #include <stat.h>
- #include <fcntl.h>
- #include "userlib.h"
- #include "rb3dh.c"
-
- #define VER "1.00"
- #define ptor(n) ((n>>5)&31)
- #define ptog(n) ((n>>10)&31)
- #define ptob(n) (n&31)
-
- char egb_work[EgbWorkSize];
-
- void pushb ( void )
- {
- int a,b;
- do
- {
- SND_joy_in_1(0,&a); /* マウス・パッド ポート0読み込み */
- SND_joy_in_1(1,&b); /* マウス・パッド ポート1読み込み */
- }
- while
- ((a&48)==48 &&(b&48)==48); /* ボタンを押すまで繰り返す */
- if((a&32)+(b&32)!=64) exit(0); /* マウス左かパッドBなら終了 */
- }
-
- void main ( int argc,char *argv[] )
- {
- char *buf;
- int x,y,n=0,p,f;
- char name[80];
-
- buf=malloc(320*240*2);
- if(argc<2 || buf==NULL)
- {
- puts("Red and Blue 3D Graphics Maker RB3D.EXP Version " VER);
- puts(" Copyright (c) Namy 1993. All rights reserved.\n");
- puts(" Usage : RUN386 RB3D [OutputFile] ([Start No.])");
- exit(0);
- }
- if(argc>2) n=atoi(argv[2]);
-
- EGB_init(egb_work,EgbWorkSize); /* EGB初期化 */
- EGB_resolution(egb_work,0,11); /* PAGE0 320*240 32768色 インタレース */
- EGB_resolution(egb_work,1,11); /* PAGE1 320*240 32768色 インタレース */
-
- LOOP:;
- EGB_displayPage(egb_work,0,1); /* PAGE0を前 PAGE0を表示 PAGE1を非表示 */
- EGB_writePage(egb_work,0); /* アクティブページを0に */
- EGB_digitize(egb_work,1); /* ページ0ビデオデジタイズ開始 */
- pushb(); /* ボタンを押すのを待つ */
-
- EGB_digitize(egb_work,0); /* ビデオデジタイズ停止 */
- USR_getBlock(egb_work,buf,0,0,319,239);
- /* 画面をbufに複写 */
- EGB_writePage(egb_work,1); /* アクティブページを1に */
- EGB_clearScreen(egb_work); /* ページ1を消去 */
- EGB_displayPage(egb_work,1,2); /* PAGE1を前 PAGE0を非表示 PAGE1を表示 */
- EGB_maskBit(egb_work,0x001f001f);
- /* ハードウェアマスク設定 0000000000011111 (青だけ) */
- for(y=0;y<240;y++)
- {
- for(x=0;x<320;x++)
- {
- p=*((short*)(buf+(y*320+x)*2));
- *((short*)(buf+(y*320+x)*2))=(ptor(p)+ptog(p)+ptob(p))/3;
- /* RGBに分解し平均をとる = モノクロにする */
- }
- USR_putBlock(egb_work,buf+y*320*2,0,0,y,319,y);
- }
- /* USR_putBlock(egb_work,buf,0,0,0,319,239);*/
-
- EGB_displayPage(egb_work,0,1); /* PAGE0を前 PAGE0を表示 PAGE1を非表示 */
- EGB_writePage(egb_work,0); /* アクティブページを0に */
- EGB_digitize(egb_work,1); /* ページ0ビデオデジタイズ開始 */
- pushb(); /* ボタンを押すのを待つ */
-
- EGB_digitize(egb_work,0); /* ビデオデジタイズ停止 */
- USR_getBlock(egb_work,buf,0,0,319,239);
- /* 画面をbufに複写 */
- EGB_writePage(egb_work,1); /* アクティブページを1に */
- EGB_displayPage(egb_work,1,2); /* PAGE1を前 PAGE0を非表示 PAGE1を表示 */
- EGB_maskBit(egb_work,0x03e003e0);
- /* ハードウェアマスク設定 0000001111100000 (赤だけ) */
- for(y=0;y<240;y++)
- {
- for(x=0;x<320;x++)
- {
- p=*((short*)(buf+(y*320+x)*2));
- *((short*)(buf+(y*320+x)*2))=((ptor(p)+ptog(p)+ptob(p))/3)<<5;
- /* RGBに分解し平均をとる = モノクロにする */
- }
- USR_putBlock(egb_work,buf+y*320*2,0,0,y,319,y);
- }
- /* USR_putBlock(egb_work,buf,0,0,0,319,239);*/
-
- USR_getBlock(egb_work,buf,0,0,319,239);
- sprintf(name,"%s%d.tif",argv[1],n);
- f=open(name,O_BINARY|O_CREAT|O_WRONLY,S_IREAD|S_IWRITE);
- write(f,tifhead,512); /* TIFFヘッダ書き込み */
- write(f,buf,320*240*2);
- close(f);
- n++;
- goto LOOP;
- }